﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using Sharp.DataTransferObject;
using Sharp.Infrastructure.Communication;
using Sharp.Platform.Mvc;
using Sharp.ServiceContracts;
using Sharp.Web.Models;
using PartialViewResult = Ext.Net.MVC.PartialViewResult;


namespace Sharp.Web.Controllers
{
    [AutomaticTemplate]
    public class OrgForBusinesController : Controller
    {
        // GET: OrgForBusines
        public ActionResult Index(string containerId)
        {
            return new PartialViewResult
            {
                Model = new OrgForBusinesIndexModel(),
                ContainerId = containerId,
                RenderMode = RenderMode.AddTo
            };
        }
        /// <summary>
        ///     分页数据
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public ActionResult GetPaged(StoreRequestParameters parameters)
        {
            using (var proxy = new ServiceProxy<IEnterpriseService>())
            {
                var pageInfo = proxy.Channel.GetJobPaged(parameters.ToPagingFeature());

                return this.Store(pageInfo.Data, pageInfo.TotalRecords);
            }
        }
        public ActionResult Create()
        {
            return new PartialViewResult
            {
                ViewName = "Create",
                Model = new OrgForBusinesModel()
                {
                    OrgTree = OrgController.OrgTree(),
                    OrgIds=Guid.Empty.ToString(),
                    PersonIds=Guid.Empty.ToString()
                }
            };
        }
        [HttpPost]
        public ActionResult Save(OrgForBusinesModel vm)
        {
            //JobDTO dto = user.To<JobDTO>();

            //using (var proxy = new ServiceProxy<IEnterpriseService>())
            //{
            //    proxy.Channel.SaveJob(dto);
            //}

            return this.FormPanel();
        }
    }
}